/* Includes ------------------------------------------------------------------*/
#include "MyApplication.h"

/* Private define-------------------------------------------------------------*/

/* Private variables----------------------------------------------------------*/
static void Buzzer_ON(void);
static void Buzzer_OFF(void);
static void Buzzer_Flip(void);
/* Public variables-----------------------------------------------------------*/
Buzzer_t Buzzer = 
{
    OFF_Status,
    Buzzer_ON,
    Buzzer_OFF,
    Buzzer_Flip
};
/* Private function prototypes------------------------------------------------*/

/*
* @name   Buzzer_ON
* @brief  打开蜂鸣器
* @param  None
* @retval None   
*/
static void Buzzer_ON()
{
    //只需开启PWM输出功能，即可让蜂鸣器响
    HAL_TIM_PWM_Start(&htim1,TIM_CHANNEL_1);
    Buzzer.Status = ON_Status;
}

/*
* @name   Buzzer_OFF
* @brief  关闭蜂鸣器
* @param  None
* @retval None   
*/
static void Buzzer_OFF()
{
    //关闭PWM输出，即关闭蜂鸣器
    HAL_TIM_PWM_Stop(&htim1,TIM_CHANNEL_1);
    Buzzer.Status = OFF_Status;
}


/*
* @name   Buzzer_Flip
* @brief  翻转蜂鸣器
* @param  None
* @retval None   
*/
static void Buzzer_Flip()
{
    //如果蜂鸣器是开启状态
    if(Buzzer.Status == ON_Status)
    {
        //切换蜂鸣器状态为关
        Buzzer.Status = OFF_Status;
        //关闭蜂鸣器
        Buzzer.Buzzer_OFF();
    }
    else    //如果蜂鸣器是关闭状态
    {
        //切换蜂鸣器状态为开
        Buzzer.Status = ON_Status;
        //开启蜂鸣器
        Buzzer.Buzzer_ON();
    }
}
/********************************************************
  End Of File
********************************************************/
